public class TrianglePrinter {
    public String print(int column, int row) {
        StringBuffer st = new StringBuffer();
        if(column !=0 && row==0 ){
            printHerizontal(column, st);
        }
        else if(row != 0 && column == 0){
            printVertical(row, st);
        }else {
            printRightTriangle(row, st);
        }

        return st.toString();
    }

    private void printRightTriangle(int row, StringBuffer st) {
        for(int i = 0;i<row;i++){
            for(int j = 0; j<= i;j++){
                st.append("*");
            }
            st.append("\n");
        }
    }

    private void printVertical(int row, StringBuffer st) {
        for(int k = 0;k<row;k++){
            st.append("*\n");
        }
    }

    private void printHerizontal(int column, StringBuffer st) {
        for(int j = 0;j< column; j++){
            st.append("*");
        }
    }
}
